import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '仓库名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '仓库编码',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '描述',
    align:"center",
    dataIndex: 'description'
   },
   {
    title: '物料分类',
    align:"center",
    dataIndex: 'materialTypeId_dictText'
   },
   {
    title: '最大容量',
    align:"center",
    dataIndex: 'maxCapacity'
   },
   {
    title: '预警容量',
    align:"center",
    dataIndex: 'warningCapacity'
   },
   {
    title: '地址',
    align:"center",
    dataIndex: 'address',
    slots: { customRender: 'pcaSlot' },
   },
   {
    title: '详细地址',
    align:"center",
    dataIndex: 'infoAddress'
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status_dictText'
   },
   {
    title: '库区摆放顺序',
    align:"center",
    dataIndex: 'sequence_dictText'
   },
   {
    title: '管理部门',
    align:"center",
    dataIndex: 'managerialDeptId_dictText'
   },
   {
    title: '仓库属性',
    align:"center",
    dataIndex: 'attribute_dictText'
   },
   {
    title: '启用库区管理',
    align:"center",
    dataIndex: 'isUseArea',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}])
     },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '仓库名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入仓库名称!'},
          ];
     },
  },
  {
    label: '仓库编码',
    field: 'code',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入仓库编码!'},
          ];
     },
    dynamicDisabled:true
  },
  {
    label: '描述',
    field: 'description',
    component: 'InputTextArea',
  },
  {
    label: '物料分类',
    field: 'materialTypeId',
    component: 'JSelectMultiple',
    componentProps:{
        dictCode:"wms_basic_material_type,name,id"
     },
  },
  {
    label: '最大容量',
    field: 'maxCapacity',
    component: 'InputNumber',
  },
  {
    label: '预警容量',
    field: 'warningCapacity',
    component: 'InputNumber',
  },
  {
    label: '地址',
    field: 'address',
    component: 'JAreaLinkage',
  },
  {
    label: '详细地址',
    field: 'infoAddress',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'status',
    defaultValue: "1",
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"is_enabled"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入状态!'},
          ];
     },
  },
  {
    label: '库区摆放顺序',
    field: 'sequence',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"wms_warehouse_sequence"
     },
  },
  {
    label: '管理部门',
    field: 'managerialDeptId',
     component: 'JSelectDept',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入管理部门!'},
          ];
     },
  },
  {
    label: '仓库属性',
    field: 'attribute',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"wms_warehouse_attribute"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入仓库属性!'},
          ];
     },
  },
  {
    label: '启用库区管理',
    field: 'isUseArea',
    defaultValue: "Y",
     component: 'JSwitch',
     componentProps:{
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}